import { knife4jSetup } from 'nest-knife4j';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { NestExpressApplication } from '@nestjs/platform-express';

/**
 * knife4j文档配置
 * @param {NestExpressApplication} app
 */
function setupKnife4j(app: NestExpressApplication) {
  const options = new DocumentBuilder()
    .setTitle('blog')
    .setDescription('my blog')
    .setVersion('1.0')
    .addTag('blog')
    .build();
  const doc = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('api', app, doc);
  knife4jSetup(app, [
    {
      name: '1.0版本',
      url: '/api-json',
      swaggerVersion: '1.0',
      location: '/api-json',
    },
  ]);
}

export default setupKnife4j;
